package com.demo.interfaceautotest;

import com.demo.connectdbtest.report.TestReport;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

/*
 * 参数传递
 * */

@Listeners(TestReport.class)
public class ParameterDeliver {
    //按照顺序传递
    //注意单元测试没有返回值否则测试方法会不执行
    @Test
    @Parameters({"firstParam", "secondParam"})
    public void testParameterDeliver(String para1, String para2) {
        System.out.println("execute testParameterDeliver=====");
        System.out.println("para1=" + para1);
        System.out.println("para2=" + para2);

    }

    @Test(dataProvider = "dataObject")
    public void test1(String para1, String para2) {
        System.out.println("execute test1 dataProvider=====");
        System.out.println("para1=" + para1);
        System.out.println("para2=" + para2);

    }

    @DataProvider(name = "dataObject")
    public Object[][] deliverJSON() {
        //好像只能返回Object[][]类型
         Object[][] objects = {{"尼古拉斯", "里斯"}, {"尼古拉斯2", "xiaoss"}};
        return objects;
//        JSONObject jsonObject = new JSONObject();
//        jsonObject.put("one",1);
//        jsonObject.put("two",2);
//        return jsonObject;
    }
}
